package com.zhy.http.okhttp.request;

import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.Callback;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.OkHttpClient.Builder;
import okhttp3.Request;
import okhttp3.Response;

public class RequestCall
{
  private Call call;
  private OkHttpClient clone;
  private long connTimeOut;
  private OkHttpRequest okHttpRequest;
  private long readTimeOut;
  private Request request;
  private long writeTimeOut;

  public RequestCall(OkHttpRequest paramOkHttpRequest)
  {
    this.okHttpRequest = paramOkHttpRequest;
  }

  private Request generateRequest(Callback paramCallback)
  {
    return this.okHttpRequest.generateRequest(paramCallback);
  }

  public void cancel()
  {
    if (this.call != null)
      this.call.cancel();
  }

  public RequestCall connTimeOut(long paramLong)
  {
    this.connTimeOut = paramLong;
    return this;
  }

  public Response execute()
    throws IOException
  {
    generateCall(null);
    return this.call.execute();
  }

  public void execute(Callback paramCallback)
  {
    generateCall(paramCallback);
    if (paramCallback != null)
      paramCallback.onBefore(this.request);
    OkHttpUtils.getInstance().execute(this, paramCallback);
  }

  public Call generateCall(Callback paramCallback)
  {
    long l1 = 10000L;
    this.request = generateRequest(paramCallback);
    long l2;
    long l3;
    if ((this.readTimeOut > 0L) || (this.writeTimeOut > 0L) || (this.connTimeOut > 0L))
      if (this.readTimeOut > 0L)
      {
        l2 = this.readTimeOut;
        this.readTimeOut = l2;
        if (this.writeTimeOut <= 0L)
          break label173;
        l3 = this.writeTimeOut;
        label76: this.writeTimeOut = l3;
        if (this.connTimeOut > 0L)
          l1 = this.connTimeOut;
        this.connTimeOut = l1;
        this.clone = OkHttpUtils.getInstance().getOkHttpClient().newBuilder().readTimeout(this.readTimeOut, TimeUnit.MILLISECONDS).writeTimeout(this.writeTimeOut, TimeUnit.MILLISECONDS).connectTimeout(this.connTimeOut, TimeUnit.MILLISECONDS).build();
      }
    for (this.call = this.clone.newCall(this.request); ; this.call = OkHttpUtils.getInstance().getOkHttpClient().newCall(this.request))
    {
      return this.call;
      l2 = l1;
      break;
      label173: l3 = l1;
      break label76;
    }
  }

  public Call getCall()
  {
    return this.call;
  }

  public OkHttpRequest getOkHttpRequest()
  {
    return this.okHttpRequest;
  }

  public Request getRequest()
  {
    return this.request;
  }

  public RequestCall readTimeOut(long paramLong)
  {
    this.readTimeOut = paramLong;
    return this;
  }

  public RequestCall writeTimeOut(long paramLong)
  {
    this.writeTimeOut = paramLong;
    return this;
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.zhy.http.okhttp.request.RequestCall
 * JD-Core Version:    0.6.2
 */